package dongtaiguihua;


public class _02走方格计数 {
    //给定m和n，表示方格的行和列，1<=m、n<=100
    public static void main(String[] args) {
        int m = 3;
        int n = 3;
        Integer ans = uniquePath(m,n);
        System.out.println(ans);



    }

    private static Integer uniquePath(int m, int n) {
        int[][] f = new int[m][n];
        int i , j;
        //先从行开始计算
        for (i = 0 ; i < m; ++i){
            //从列开始计算
            for (j = 0 ; j < n; ++j){
                if ( i == 0 || j ==0){ //第一行第一列
                    f[i][j] = 1;
                }else {
                    f[i][j] = f[i-1][j] + f[i][j-1];
                }
            }
        }
        return f[m-1][n-1];
    }

}
